package com.edu.study.base.stuProductCatalogTemplateData.controller;

import java.util.List;

import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.study.base.stuProductCatalogTemplateData.domain.StuProductCatalogTemplateData;
import com.edu.study.base.stuProductCatalogTemplateData.service.IStuProductCatalogTemplateDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品组件配置模板数据Controller
 * 
 * @author zw
 * @date 2021-05-11
 */
@RestController
@RequestMapping("/stuProductCatalogTemplateData/stuProductCatalogTemplateData")
public class StuProductCatalogTemplateDataController extends BaseController
{
    @Autowired
    private IStuProductCatalogTemplateDataService stuProductCatalogTemplateDataService;

    /**
     * 查询产品组件配置模板数据列表
     */
    @PreAuthorize("@ss.hasPermi('stuProductCatalogTemplateData:stuProductCatalogTemplateData:list')")
    @GetMapping("/list")
    public TableDataInfo list(StuProductCatalogTemplateData stuProductCatalogTemplateData)
    {
        startPage();
        List<StuProductCatalogTemplateData> list = stuProductCatalogTemplateDataService.selectStuProductCatalogTemplateDataList(stuProductCatalogTemplateData);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('stuProductCatalogTemplateData:stuProductCatalogTemplateData:list')")
    @GetMapping("/list2")
    public TableDataInfo list2(StuProductCatalogTemplateData stuProductCatalogTemplateData)
    {
        startPage();
        List<StuProductCatalogTemplateData> list = stuProductCatalogTemplateDataService.selectStuProductCatalogTemplateDataList2(stuProductCatalogTemplateData);
        return getDataTable(list);
    }

    /**
     * 导出产品组件配置模板数据列表
     */
    @PreAuthorize("@ss.hasPermi('stuProductCatalogTemplateData:stuProductCatalogTemplateData:export')")
    @Log(title = "产品组件配置模板数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StuProductCatalogTemplateData stuProductCatalogTemplateData)
    {
        List<StuProductCatalogTemplateData> list = stuProductCatalogTemplateDataService.selectStuProductCatalogTemplateDataList(stuProductCatalogTemplateData);
        ExcelUtil<StuProductCatalogTemplateData> util = new ExcelUtil<StuProductCatalogTemplateData>(StuProductCatalogTemplateData.class);
        return util.exportExcel(list, "stuProductCatalogTemplateData");
    }

    /**
     * 获取产品组件配置模板数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('stuProductCatalogTemplateData:stuProductCatalogTemplateData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(stuProductCatalogTemplateDataService.selectStuProductCatalogTemplateDataById(id));
    }

    /**
     * 新增产品组件配置模板数据
     */
    @PreAuthorize("@ss.hasPermi('stuProductCatalogTemplateData:stuProductCatalogTemplateData:add')")
    @Log(title = "产品组件配置模板数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StuProductCatalogTemplateData stuProductCatalogTemplateData)
    {
        stuProductCatalogTemplateData = (StuProductCatalogTemplateData)BeanUtils.initBeanPublicProperties(stuProductCatalogTemplateData,"add");
        stuProductCatalogTemplateData.setCatalogCode(stuProductCatalogTemplateData.getId());
        return toAjax(stuProductCatalogTemplateDataService.insertStuProductCatalogTemplateData(stuProductCatalogTemplateData));
    }

    /**
     * 修改产品组件配置模板数据
     */
    @PreAuthorize("@ss.hasPermi('stuProductCatalogTemplateData:stuProductCatalogTemplateData:edit')")
    @Log(title = "产品组件配置模板数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StuProductCatalogTemplateData stuProductCatalogTemplateData)
    {
        stuProductCatalogTemplateData = (StuProductCatalogTemplateData)BeanUtils.initBeanPublicProperties(stuProductCatalogTemplateData,"update");
        return toAjax(stuProductCatalogTemplateDataService.updateStuProductCatalogTemplateData(stuProductCatalogTemplateData));
    }

    /**
     * 删除产品组件配置模板数据
     */
    @PreAuthorize("@ss.hasPermi('stuProductCatalogTemplateData:stuProductCatalogTemplateData:remove')")
    @Log(title = "产品组件配置模板数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(stuProductCatalogTemplateDataService.deleteStuProductCatalogTemplateDataByIds(ids));
    }
}
